home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / recode.lha / recode-3.2.4 / iconibmp.c < prev    next >
C/C++ Source or Header  |  1992-08-19  |  4KB  |  165 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1990 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1988.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #define STEP    iconqnx_ibmpc
  21. #include <stdio.h>
  22. #include "common.h"
  23.  
  24. /* Previous obsolete lex code:
  25.  
  26. Esc            \031
  27.  
  28. %%
  29.  
  30. {Esc}Aa            { output (0x85); }
  31. {Esc}Ae            { output (0x8A); }
  32. {Esc}Au            { output (0x97); }
  33.  
  34. {Esc}Be            { output (0x82); }
  35. {Esc}BE            { output (0x90); }
  36.  
  37. {Esc}Ca            { output (0x83); }
  38. {Esc}Ce            { output (0x88); }
  39. {Esc}Ci            { output (0x8C); }
  40. {Esc}Co            { output (0x93); }
  41. {Esc}Cu            { output (0x96); }
  42.  
  43. {Esc}He            { output (0x89); }
  44. {Esc}Hi            { output (0x8B); }
  45. {Esc}Hu            { output (0x81); }
  46.  
  47. {Esc}Kc            { output (0x87); }
  48. {Esc}KC            { output (0x80); }
  49.  
  50. */
  51.  
  52. #define ESCAPE 0x19        /* Escape for diacritic application */
  53. #define ENDLINE 0x1E        /* End-line code for QNX */
  54.  
  55. void
  56. STEP (FILE *input_file, FILE *output_file)
  57. {
  58.   int input_char;        /* current character */
  59.  
  60.   while (input_char = getc (input_file), input_char != EOF)
  61.     {
  62.       switch (input_char)
  63.     {
  64.     case ENDLINE:
  65.       putc (0x0D, output_file);
  66.       putc (0x0A, output_file);
  67.       break;
  68.  
  69.     case ESCAPE:
  70.       input_char = getc (input_file);
  71.       switch (input_char)
  72.         {
  73.         case 'A':
  74.           input_char = getc (input_file);
  75.           switch (input_char)
  76.         {
  77.         case 'a': input_char = 0x85; break;
  78.         case 'e': input_char = 0x8a; break;
  79.         case 'u': input_char = 0x97; break;
  80.           
  81.         default:
  82.           putc (ESCAPE, output_file);
  83.           putc ('A', output_file);
  84.           if (input_char == EOF)
  85.             return;
  86.         }
  87.           break;
  88.  
  89.         case 'B':
  90.           input_char = getc (input_file);
  91.           switch (input_char)
  92.         {
  93.         case 'e': input_char = 0x82; break;
  94.         case 'E': input_char = 0x90; break;
  95.           
  96.         default:
  97.           putc (ESCAPE, output_file);
  98.           putc ('B', output_file);
  99.           if (input_char == EOF)
  100.             return;
  101.         }
  102.           break;
  103.  
  104.         case 'C':
  105.           input_char = getc (input_file);
  106.           switch (input_char)
  107.         {
  108.         case 'a': input_char = 0x83; break;
  109.         case 'e': input_char = 0x88; break;
  110.         case 'i': input_char = 0x8c; break;
  111.         case 'o': input_char = 0x93; break;
  112.         case 'u': input_char = 0x96; break;
  113.           
  114.         default:
  115.           putc (ESCAPE, output_file);
  116.           putc ('C', output_file);
  117.           if (input_char == EOF)
  118.             return;
  119.         }
  120.           break;
  121.  
  122.         case 'H':
  123.           input_char = getc (input_file);
  124.           switch (input_char)
  125.         {
  126.         case 'e': input_char = 0x89; break;
  127.         case 'i': input_char = 0x8b; break;
  128.         case 'u': input_char = 0x81; break;
  129.           
  130.         default:
  131.           putc (ESCAPE, output_file);
  132.           putc ('H', output_file);
  133.           if (input_char == EOF)
  134.             return;
  135.         }
  136.           break;
  137.  
  138.         case 'K':
  139.           input_char = getc (input_file);
  140.           switch (input_char)
  141.         {
  142.         case 'c': input_char = 0x87; break;
  143.         case 'C': input_char = 0x80; break;
  144.           
  145.         default:
  146.           putc (ESCAPE, output_file);
  147.           putc ('K', output_file);
  148.           if (input_char == EOF)
  149.             return;
  150.         }
  151.           break;
  152.           
  153.         default:
  154.           putc (ESCAPE, output_file);
  155.           if (input_char == EOF)
  156.         return;
  157.         }
  158.       /* fall through */
  159.  
  160.     default:
  161.       putc (input_char, output_file);
  162.     }
  163.     }
  164. }
  165.